package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.common.result.ResultCodeEnum;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author XC
 * @version 1.0
 * @description
 * @knowledge
 */

@ControllerAdvice
public class GlobalExceptionHandler {
    /*
     * 异常处理方法
     */
    @ExceptionHandler
    @ResponseBody
    public Result exception(Exception e) {
        e.printStackTrace();
        // return Result.fail(ResultCodeEnum.UPLOAD_FAIL);
        return Result.fail();
    }

    @ExceptionHandler
    @ResponseBody
    public Result leaseException(LeaseException e) {
        e.printStackTrace();
        return Result.fail(e.getCode(), e.getMessage());
    }
}
